static void
gtk_box_layout_compute_opposite_size (GtkBoxLayout *self,
GtkWidget *widget,
- int for_size,
int *minimum,
int *natural,
int *min_baseline,
int *nat_baseline)
+{
+ GtkWidget *child;
+ int largest_min = 0, largest_nat = 0;
+
+ for (child = gtk_widget_get_first_child (widget);
+ child != NULL;
+ child = gtk_widget_get_next_sibling (child))
+ {
+ int child_min = 0;
+ int child_nat = 0;
+
+ if (!gtk_widget_should_layout (child))
+ continue;
+
+ gtk_widget_measure (child,
+ OPPOSITE_ORIENTATION (self->orientation),
+ -1,
+ &child_min, &child_nat,
+ NULL, NULL);
+
+ largest_min = MAX (largest_min, child_min);
+ largest_nat = MAX (largest_nat, child_nat);
+ }
+
+ *minimum = largest_min;
+ *natural = largest_nat;
+}
+
+static void
+gtk_box_layout_compute_opposite_size_for_size (GtkBoxLayout *self,
+ GtkWidget *widget,
+ int for_size,
+ int *minimum,
+ int *natural,
+ int *min_baseline,
+ int *nat_baseline)
{
GtkWidget *child;
int nvis_children;
if (self->orientation != orientation)
{
- gtk_box_layout_compute_opposite_size (self, widget, for_size,
- minimum, natural,
- min_baseline, nat_baseline);
+ if (for_size < 0)
+ {
+ gtk_box_layout_compute_opposite_size (self, widget,
+ minimum, natural,
+ min_baseline, nat_baseline);
+ }
+ else
+ {
+ gtk_box_layout_compute_opposite_size_for_size (self, widget, for_size,
+ minimum, natural,
+ min_baseline, nat_baseline);
+ }
}
else
{
'unresolvable.css',
'unresolvable.ref.ui',
'unresolvable.ui',
+ 'vbox-with-max-width-chars-label.ref.ui',
+ 'vbox-with-max-width-chars-label.ui',
'window-border-width.ref.ui',
'window-border-width.ui',
'window-default-size.ref.ui',
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <object class="GtkWindow">
+ <property name="decorated">0</property>
+ <child>
+ <object class="GtkBox">
+ <property name="orientation">horizontal</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="label">Hello World</property>
+ <property name="wrap">1</property>
+ <property name="max-width-chars">1</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+</interface>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <object class="GtkWindow">
+ <property name="decorated">0</property>
+ <child>
+ <object class="GtkBox">
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="label">Hello World</property>
+ <property name="wrap">1</property>
+ <property name="max-width-chars">1</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+</interface>